<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表格隔行换色</title>
    <script>

        window.onload = function () {

            let trObjArr = document.getElementsByTagName("tr");

            for (let i = 1; i < trObjArr.length; i++) {
                if(i%2==0){

                    trObjArr[i].style.backgroundColor="cyan";
                }else{
                    trObjArr[i].style.backgroundColor = "blue";
                }
            }
        }
    </script>
</head>
<body>
<table id="tab" border="1" width="800" align="center" >

    <tr style="background-color: #999999;">
        <th>分类ID</th>
        <th>分类名称</th>
        <th>分类描述</th>
        <th>操作</th>
    </tr>
    <tr>
        <td>1</td>
        <td>奥特曼</td>
        <td>奥特曼类商品</td>
        <td><a href="">修改</a>|<a href="">删除</a></td>
    </tr>
    <tr>
        <td>2</td>
        <td>漫威</td>
        <td>漫威类商品</td>
        <td><a href="">修改</a>|<a href="">删除</a></td>
    </tr>
    <tr>
        <td>3</td>
        <td>DC</td>
        <td>DC商品</td>
        <td><a href="">修改</a>|<a href="">删除</a></td>
    </tr>
    <tr>
        <td>4</td>
        <td>葫芦娃饰品</td>
        <td>葫芦娃类商品</td>
        <td><a href="">修改</a>|<a href="">删除</a></td>
    </tr>
</table>
</body>
</html>